<%@ page import="bean.Student" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="bean.Teacher" %><%--
  Created by IntelliJ IDEA.
  User: 86177
  Date: 2023/6/24
  Time: 21:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%!
        Connection connection=null;
        PreparedStatement pre=null;
        ResultSet resone=null;
        ResultSet restwo=null;
        ResultSet resthree=null;
        String sqlone="select * from book_t_rd where teacherid="+"?";
        String sqltwo="select * from book_t_sn where teacherid="+"?";
        String sqlthree="select * from book_t_st where teacherid="+"?";
    %>
    <%
        Teacher stu= (Teacher) request.getSession().getAttribute("user");
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/library", "root", "20030607");
        }catch (Exception e){
            out.print(e);
            e.printStackTrace();
        }
    %>
    <style>
        table th{
            background-color: #00aa00;
            color: white;
        }
    </style>
</head>
<body>
<%
    try {
        pre=connection.prepareStatement(sqlone);
        pre.setString(1,stu.gettid());
        resone=pre.executeQuery();
        pre=connection.prepareStatement(sqltwo);
        pre.setString(1,stu.gettid());
        restwo=pre.executeQuery();
        pre=connection.prepareStatement(sqlthree);
        pre.setString(1,stu.gettid());
        resthree=pre.executeQuery();
    }catch (Exception e){
        out.print(e);
        e.printStackTrace();
    }
%>
<table border="1px">
    <tr>
        <th>座位编号</th>
        <th>开始时间</th>
        <th>结束时间</th>
        <th>签到时间</th>
        <th>预约时间</th>
        <th>签离时间</th>
        <th>状态</th>
    </tr>
    <%
        try {
            while (resone.next()){
                out.print("<tr>");
                out.print("<td>"+resone.getString("readroomnum")+"</td>");
                out.print("<td>"+resone.getTimestamp("starttime")+"</td>");
                out.print("<td>"+resone.getTimestamp("endtime")+"</td>");
                out.print("<td>"+resone.getTimestamp("arrivetime")+"</td>");
                out.print("<td>"+resone.getTimestamp("submittime")+"</td>");
                out.print("<td>"+resone.getTimestamp("actualendtime")+"</td>");
                out.print("<td>"+resone.getString("status")+"</td>"+"</tr>");
            }
            while (restwo.next()){
                out.print("<tr>");
                out.print("<td>"+restwo.getString("seminarnum")+"</td>");
                out.print("<td>"+restwo.getTimestamp("starttime")+"</td>");
                out.print("<td>"+restwo.getTimestamp("endtime")+"</td>");
                out.print("<td>"+restwo.getTimestamp("arrivetime")+"</td>");
                out.print("<td>"+restwo.getTimestamp("submittime")+"</td>");
                out.print("<td>"+restwo.getTimestamp("actualendtime")+"</td>");
                out.print("<td>"+restwo.getString("status")+"</td>"+"</tr>");
            }
            while (resthree.next()){
                out.print("<tr>");
                out.print("<td>"+resthree.getString("seatnum")+"</td>");
                out.print("<td>"+resthree.getTimestamp("starttime")+"</td>");
                out.print("<td>"+resthree.getTimestamp("endtime")+"</td>");
                out.print("<td>"+resthree.getTimestamp("arrivetime")+"</td>");
                out.print("<td>"+resthree.getTimestamp("submittime")+"</td>");
                out.print("<td>"+resthree.getTimestamp("actualendtime")+"</td>");
                out.print("<td>"+resthree.getString("status")+"</td>"+"</tr>");
            }
            resthree.close();
            restwo.close();
            resone.close();
            pre.close();
            connection.close();
        }catch (Exception e){
            e.printStackTrace();
        }

    %>

</table>
</body>
</html>
